﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <!--[if lt IE 9]>
    <script src="Scripts/json2.min.js"></script>
    <![endif]-->
    <script src="Scripts/jquery-1.8.2.min.js"></script>
    <script src="Scripts/jquery.signalR.min.js"></script>
</head>
<body>
    <script type="text/javascript">
        $(function () {
            var connection = $.connection('/SignalR', {},true);

            connection.received(function (data) {
                $('#messages').append('<li>' + data + '</li>');
            });

            connection.error(function(error) {
                console.dir(error.context.status);
            });

            connection.start();

            $("#broadcast").click(function () {
                connection.send($('#msg').val());
            });
            $("#btnStop").click(function () {
                connection.stop();
            });
        });

    </script>
    <h2>Message</h2>
    <input type="text" id="msg" />
    <input type="button" id="broadcast" value="发送" />
    <input type="button" id="btnStop" value="停止" />
    <ul id="messages"></ul>
</body>
</html>
